import Vue from 'vue'
import VueRouter from 'vue-router'
import HomeView from '../views/HomeView.vue'
import Layout from "@/views/Layout.vue";

Vue.use(VueRouter)

const routes = [
  //   ==== 登录  =====
  {
    path: '/login',
    name: 'Login',
    component: ()=> import('@/views/Login.vue'),
  },
  //   ===== 主页 =====
  {
    path: '/',
    name: 'Layout',
    component: Layout,
    redirect: '/home',
    children: [  //主路由
      {
        path: 'home',
        name: 'Home',
        component: ()=>import('@/views/HomeView.vue')
      },
      // ==== User ====
      {
        path: 'studentList',
        name: 'StudentList',
        component: ()=>import('@/views/student/Student.vue')
      },
      // ===== teacher ====


    ]
  },
  // {
  //   path: "*",
  //   component:() => import('@/views/404.vue')
  // }
]

const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes
})

// router.beforeEach((to, from, next) => {
//   // if (to.path === '/login') next()
//   // const admin = Cookies.get("admin")
//   // if (!admin && to.path !== '/login') return next("/login") //强制退回到登录页
//   //直接放行
//   next()
// })

export default router
